package com.sven.zuulgateway.config2;

import com.netflix.zuul.ZuulFilter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;


/**
 *  如果是post过滤器抛出的异常，将没有后续的post过滤器起对接，所以还需要自定义了一个error类型的过滤器，仅处理来自post过滤器引起的异常
 */
// @Component
public class PostThrowExceptionFilter extends ZuulFilter {
    private static Logger logger = LoggerFactory.getLogger(PostThrowExceptionFilter.class);

    @Override
    public String filterType() {
        return "post";
    }

    @Override
    public int filterOrder() {
        return 0;
    }

    @Override
    public boolean shouldFilter() {
        return true;
    }

    @Override
    public Object run() {
        System.out.println("---------PostThrowExceptionFilter-----run----------");
        int[] arr = {3,9,8};
        System.out.println(arr[9]);

        return null;
    }

}
